<ion-view view-title="添加员工" show-tabs>
    <ion-content class="wrap-light2">
    <form name="addEmployeeFrom" class="editing" ng-submit="add();" novalidate>
        <ion-list>

            <ion-item class="item-input">
                <span class="input-label">姓名</span>
                <input type="text" name="name" maxlength="20" required placeholder="姓名" ng-model="newEmployee.profile.name">
                <span class="ion-minus-circled" ng-show="addEmployeeFrom.name.$dirty && addEmployeeFrom.name.$invalid "></span>
            </ion-item>

            <ion-item class="item-input">
                <span class="input-label">手机</span>
                <input type="text" name="label" maxlength="11" ng-model="newEmployee.profile.phones[0].label">
                <input type="tel" name="phone" maxlength="11" required placeholder="手机号码" ng-model="newEmployee.profile.phones[0].number">
                <span class="ion-minus-circled" ng-show= "newEmployee.phones[0].number.$dirty && addEmployeeFrom.phones[0].number.$invalid "></span>
            </ion-item>
            <ion-item class="item-base item-icon-right" ng-click="openModal()">
                <span class="input-label">部门</span>
                <span ng-repeat="dept in newEmployee.profile.departments">{{dept.name}}</span>
                <span class="dark2" ng-if="!newEmployee.profile.departments.length">请选择</span>
                <i class="icon ion-android-arrow-dropright select-arrow"></i>

            </ion-item>

            <ion-item class="item-select">
              <span class="input-label">职能</span>
              <select ng-model="newEmployee.profile.roleName">
                <option ng-repeat="role in roles.value_set" value="{{role.name}}">{{role.name}}</option>
              </select>
            </ion-item>
            <ion-item class="item-select">
                <span class="input-label">状态</span>
                
                <select ng-model="newEmployee.profile.state">
                  <option value="在职" ng-selected="true">在职</option>
                  <option value="休假中">休假中</option>
                  <option value="离职">离职</option>
                </select>
            </ion-item>
            <ion-toggle ng-model="isSysUser" toggle-class="toggle-royal"><span class="list-label">开启账号</span></ion-toggle>

            <ion-item class="text-center">
              初始密码： 888888，分配后请员工自行修改
            </ion-item>

            <ion-item class="item item-divider margin-top-large" ng-click="toggleFeilds()">
                详细资料
                <i class="button button-icon pull-right" ng-class="{'ion-ios-arrow-up':showCustomerFeilds,'ion-ios-arrow-down':!showCustomerFeilds}"></i>
            </ion-item>

            <div ng-show="!showCustomerFeilds">
                <ion-item class="item-input">
                    <span class="input-label">邮箱</span>
                    <input type="email" name="emails" maxlength="30" placeholder="工作邮箱" ng-model="newEmployee.emails[0].address">
                    <span class="ion-minus-circled" ng-show="addEmployeeFrom.emails.$dirty && addEmployeeFrom.emails.$invalid "></span>
                </ion-item>

                <ion-item class="item-input radio-group item-icon-right">
                    <span class="input-label">性别</span>
                    <ion-radio ng-model="newEmployee.profile.sex" ng-value="'男'">男</ion-radio>
                    <ion-radio ng-model="newEmployee.profile.sex" ng-value="'女'">女</ion-radio>
                    <span class="ion-minus-circled" ng-show="addEmployeeFrom.sex.$dirty && addEmployeeFrom.sex.$invalid"></span>
                </ion-item>

                <ion-item class="item-input">
                    <span class="input-label">生日</span>
                    <input type="date" name="birthday" maxlength="30" placeholder="出生日期" ng-model="newEmployee.profile.birthday">
                    <span class="ion-minus-circled" ng-show="addEmployeeFrom.birthday.$dirty && addEmployeeFrom.birthday.$invalid "></span>
                </ion-item>

                <ion-item class="item-input">
                    <span class="input-label">住址</span>
                    <input type="text" name="province" maxlength="10" placeholder="省" ng-model="newEmployee.profile.address.province" />
                    <input type="text" name="city" maxlength="10" placeholder="市" ng-model="newEmployee.profile.address.city" />
                    <input type="text" name="region" maxlength="10" placeholder="区/县" ng-model="newEmployee.profile.address.region" />
                </ion-item>
                <ion-item class="item-input item-borderless">
                    <span class="input-label"></span>
                    <input type="text" name="street" maxlength="50" placeholder="详细地址" ng-model="newEmployee.profile.address.street" />
                    <span class="ion-minus-circled" ng-show= "newEmployee.addresses.$dirty && addEmployeeFrom.addresses.$invalid "></span>
                </ion-item>

                <ion-item class="item-input">
                    <span class="input-label">手机2</span>
                    <input type="text" name="label" maxlength="11" ng-model="newEmployee.profile.phones[1].label">
                    <input type="tel" name="phone" maxlength="11" placeholder="手机号码" ng-model="newEmployee.profile.phones[1].number">
                    <span class="ion-minus-circled" ng-show= "newEmployee.phones[1].number.$dirty && addEmployeeFrom.phones[1].number.$invalid "></span>
                </ion-item>
                <ion-item class="item-input">
                    <span class="input-label">邮箱</span>
                    <input type="email" name="email" maxlength="30" placeholder="私人邮箱" ng-model="newEmployee.profile.email">
                    <span class="ion-minus-circled" ng-show="addEmployeeFrom.email.$dirty && addEmployeeFrom.email.$invalid "></span>
                </ion-item>


                <ion-item class="item-input light-bg">
                    <span class="list-label">备注</span>
                    <textarea rows="3" ng-model="newEmployee.profile.remark"></textarea>
                </ion-item>
            </div>
            <button class="button button-block button-royal" type="submit">确认添加</button>

        </ion-list>
    </form>
    </ion-content>
</ion-view>
